package com.paddyi.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.paddyi.model.Account;
import com.paddyi.mapper.AccountMapper;
import com.paddyi.service.IAccountService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 *  (Account)
 * @author paddy
 * @since  2019-08-09 12:00:53
 */
@Service
public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> implements IAccountService {

    @Autowired
    AccountMapper accountMapper;


    @Override
    public boolean pay(Account account) {
        int rows = accountMapper.pay(account);
        if(rows !=1){
//            throw new RuntimeException();
        }
        return true;
    }

    @Override
    public Account findAccountByUserId(Long userId) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("user_id",userId);
        return accountMapper.selectOne(queryWrapper);
    }

    public boolean confirm(Account account) {
        final int rows = accountMapper.confirm(account);
        return Boolean.TRUE;
    }

    public boolean cancel(Account account) {
        final int rows = accountMapper.cancel(account);
        if (rows != 1) {
        }
        return Boolean.TRUE;
    }
}
